package com.logic.presenter

import com.logic.contract.DailyInventoryRfidContract
import com.sinopec.basemodule.api.BaseModuleApi
import com.sinopec.basemodule.http.CommonObserver
import com.sinopec.basemodule.http.ExceptionEngine
import com.sinopec.basemodule.launchcontract.UHFDailyInventoryResultLaunch
import com.sinopec.basemodule.model.DailyInventoryApiRequestModel

/**
 * @author lwj
 * @ClassName: DailyInventoryRfidPresenter
 * @Description: 日常盘库库-rfid扫码界面
 */
class DailyInventoryRfidPresenter(view: DailyInventoryRfidContract.View) :
    DailyInventoryRfidContract.Presenter(view) {

    /**
     * 确认入库-编码校验
     */
    override fun confirmDailyInventory(model: DailyInventoryApiRequestModel) {
        val resultObservable = BaseModuleApi.confirmDailyInventory(model)
        toSubscribe(resultObservable, object : CommonObserver<Any?>(mView.context) {
            override fun onNext(s: Any) {
                UHFDailyInventoryResultLaunch.setResult(mView.context, true)
                mView.showMessage("操作成功！")
                mView.context.finish()
            }

            override fun onError(t: ExceptionEngine.ResponseThrowable) {
                UHFDailyInventoryResultLaunch.setResult(mView.context, true)
                mView.showMessage("操作成功！")
                mView.context.finish()
                //mView.showMessage(t.message)
            }
        })
    }
}